{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">功能菜单/节点</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray-2">客户<font>*</font>
			</td>
			<td>
				<select name="purveyor_id" lay-verify="required" lay-search lay-reqText="请选择客户">
					{volist name='punterList' id='pl'}
					<option value="{$pl.id}" {if isset($detail.punter_id) && $detail.punter_id==$pl.id} selected {/if} >{$pl.name}</option>
					{/volist}
				</select>
			</td>
			<td class="layui-td-gray-2">产品<font>*</font>
			</td>
			<td>
				<select name="material_dossier_id" lay-verify="required" lay-search  lay-reqText="请选择产品">
					{volist name='matList' id='ml' }
					<option value="{$ml.id}" {if isset($detail.ml) && $detail.ml==$pl.id} selected {/if}>{$ml.name}</option>
					{/volist}
				</select>
			</td>
<!--			<td class="layui-td-gray">客户料号<font>*</font>-->
<!--			</td>-->
<!--			<td>-->
<!--				<input type="text" name="part_no" value="{$detail.part_no|default=''}" lay-verify="required" autocomplete="off" placeholder="请输入客户料号"-->
<!--					   lay-reqText="请输入客户料号" class="layui-input">-->
<!--			</td>-->
		</tr>
		<tr>
<!--			<td class="layui-td-gray">客户品名<font>*</font>-->
<!--			</td>-->
<!--			<td>-->
<!--				<input type="text" name="name" value="{$detail.name|default=''}" lay-verify="required" autocomplete="off" placeholder="请输入客户品名"-->
<!--					lay-reqText="请输入客户品名" class="layui-input">-->
<!--			</td>-->
			<td class="layui-td-gray">价格<font>*</font>
			</td>
			<td>
				<input type="text" name="price" value="{$detail.price|default=''}" maxlength="9" onkeyup="digitalFiltering(this,4)" lay-verify="required" autocomplete="off" placeholder="请输入价格"
					lay-reqText="请输入价格" class="layui-input">
			</td>
			<td class="layui-td-gray">有效月份<font>*</font>
			</td>
			<td>
				<input type="text" name="time" value="{$detail.time|default=''}" readonly lay-verify="required"  placeholder="请选择时间"
					lay-reqText="请选择时间" id="time" class="layui-input">
			</td>
		</tr>
	</table>
	<div class="py-3">
		<input type="hidden" name="id" value="{$id}">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,level=0,laydate = layui.laydate;

		level = $('[name="pid"]').find('[selected=""]').attr('title');
		if(level === undefined){
			level=0;
		}
		console.log(level);
		//监听提交
		form.on('submit(webform)', function (data) {
			form.on('select(pid)', function(data){
				level = data.elem[data.elem.selectedIndex].title;
			})
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					setTimeout(function(){
						parent.parent.location.reload();
					},1000);									
				}
			}
			tool.post("{:url('add')}", data.field, callback);
			return false;
		});
		laydate.render({
			elem: '#time'
			,type:'month'
		});
	}
</script>
{/block}
<!-- /脚本 -->